<?php

require 'bootstrap.php';

$container = new \Louis\Container();
$routeCollector = new \Louis\Router\RouteCollector();

$routeCollector->addGroup("/data", function ($routeCollector){
    $routeCollector->addRoute('GET', '/users', 'get_all_users_handler');
});
$routeCollector->addRoute('GET', '/users', 'get_all_users_handler');
$routeCollector->addRoute('GET', '/user/{id:\d+}', 'get_user_handler');
$routeCollector->addRoute('GET', '/articles/{id:\d+}[/{title}]', 'get_article_handler');



$dispatcher = $routeCollector->getDispatcher();


// Fetch method and URI from somewhere
$httpMethod = $_SERVER['REQUEST_METHOD'];
$uri = $_SERVER['REQUEST_URI'];
$uri = "/users";
// Strip query string (?foo=bar) and decode URI
if (false !== $pos = strpos($uri, '?')) {
    $uri = substr($uri, 0, $pos);
}
$uri = rawurldecode($uri);

//$routeInfo = $dispatcher->dispatch($httpMethod, $uri);
$response = $dispatcher->respond($httpMethod, $uri);

function get_all_users_handler(){
    return "23423";
}


